#ifndef _SHELL_SIMPLE_SHELL_H_
#define _SHELL_SIMPLE_SHELL_H_

#include <shell/function.h>
#include <utils/dictionnary.h>


namespace shell
{

enum baud_rate
{
  BR300    = 300,
  BR600    = 600,
  BR1200   = 1200,
  BR2400   = 2400,
  BR4800   = 4800,
  BR9600   = 9600,
  BR14400  = 14400,
  BR19200  = 19200,
  BR28800  = 28800,
  BR38400  = 38400,
  BR57600  = 57600,
  BR115200 = 115200,
  BRMIN    = BR300,
  BRMAX    = BR115200
};

class simple_shell
{
public:

  simple_shell(baud_rate rate);

  void update(void);

  template <typename... _Args>
  void add_function(String name, utils::function<int(_Args...)> const& func)
  { _functions.insert(name, command(func)); }

  void print(int indent = 0)
  {
    for (int i = 0; i < indent; ++i)
      Serial.print("  ");

    Serial.println("Function dictionnary:");
    _functions.print(indent + 1);
  }

private:

  void prompt(void);

  utils::dictionnary<command> _functions;
  char _buffer[100];
  char* _argv[10];
  int _argc;
  int _pos;
  int _return;
};

}

#endif // _SHELL_SIMPLE_SHELL_H_
